//
//  BiliHotVideo.swift
//  RoBiliBiliHotVideo
//
//  Created by 罗万能 on 2025/7/6.
//
import SwiftData
import Foundation

@available(macOS 14, *)
public typealias BiliHotVideo = BiliHotVideoV2

@available(macOS 14, *)
@Model
public class BiliHotVideoV1{
    public var videoItem: VideoItem
    public var parsingVideoItem: ParsingVideo
    public var id: UUID
    public var createdDate: Date
    public var localVideoUrl: URL?
    
    
    public var videoResumeData: Data?
    public var videoDownloadProgress: Double
    
    public var localAuthorPic: URL?
    public var localFirstFramePic: URL?
    public var localTitlePic: URL?
    public init(videoItem: VideoItem, parsingVideoItem: ParsingVideo, id: UUID, createdDate: Date, localVideoUrl: URL? = nil, localTitlePic: URL? = nil, videoResumeData: Data? = nil, videoDownloadProgress: Double, authorPic: URL? = nil, firstFramePic: URL? = nil) {
        self.videoItem = videoItem
        self.parsingVideoItem = parsingVideoItem
        self.id = id
        self.createdDate = createdDate
        self.localVideoUrl = localVideoUrl
        
        self.localTitlePic = localTitlePic
        self.videoResumeData = videoResumeData
        self.videoDownloadProgress = videoDownloadProgress
        self.localAuthorPic = authorPic
        self.localFirstFramePic = firstFramePic
    }

    public convenience init(videoItem: VideoItem, parsingVideoItem: ParsingVideo){
        self.init(videoItem: videoItem, parsingVideoItem: parsingVideoItem, id: UUID(), createdDate: Date.now,  videoDownloadProgress: 0)
    }
}
@available(macOS 14, *)
@Model
public class BiliHotVideoV2{
    public var videoItem: VideoItem
    public var parsingVideoItem: ParsingVideo
    public var id: UUID
    public var createdDate: Date
    public var localVideoUrl: URL?
    
    
    public var videoResumeData: Data?
    public var videoDownloadProgress: Double
    
    public var localAuthorPic: URL?
    public var localFirstFramePic: URL?
    public var localTitlePic: URL?
    public init(videoItem: VideoItem, parsingVideoItem: ParsingVideo, id: UUID, createdDate: Date, localVideoUrl: URL? = nil, localTitlePic: URL? = nil, videoResumeData: Data? = nil, videoDownloadProgress: Double, authorPic: URL? = nil, firstFramePic: URL? = nil) {
        self.videoItem = videoItem
        self.parsingVideoItem = parsingVideoItem
        self.id = id
        self.createdDate = createdDate
        self.localVideoUrl = localVideoUrl
        
        self.localTitlePic = localTitlePic
        self.videoResumeData = videoResumeData
        self.videoDownloadProgress = videoDownloadProgress
        self.localAuthorPic = authorPic
        self.localFirstFramePic = firstFramePic
    }

    public convenience init(videoItem: VideoItem, parsingVideoItem: ParsingVideo){
        self.init(videoItem: videoItem, parsingVideoItem: parsingVideoItem, id: UUID(), createdDate: Date.now,  videoDownloadProgress: 0)
    }
}
@available(macOS 14, *)
extension BiliHotVideo{
    
    @Transient public var bVid: String{
        get{
            return videoItem.bvid
        }
    }
    @Transient public var title: String{
        get{
            return videoItem.title
        }
    }
}
